<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Vue中多个组件过渡</title>  
    <script src="./vue.js"></script>
    <style>
        .v-enter,.v-leave-to{
            opacity: 0;
        }
        .v-enter-active,.v-leave-active{
            transition: opacity 1s;
        }
    </style>
</head>
<body>
    <div id="root">
        <transition>
            <component :is=type></component>
        </transition>
        <button @click=handleBtnClick>切换</button>
    </div>
    <script>
        Vue.component('child',{
            template:'<div>child</div>'
        })
        Vue.component('child-one',{
            template:'<div>child-one</div>'
        })


        var vm = new Vue({
            el:'#root',
            data:{
                type:'child'
            },
            methods:{
                handleBtnClick:function(){
                    this.type = this.type==='child'?'child-one':'child'
                }
            }
        })
    </script>
</body>
</html>